/*  ------------------------------------------------------------------ajax comments - add to functions.php ------- */

add_action('comment_post', 'ajaxify_comments',20, 2);
function ajaxify_comments($comment_ID, $comment_status){
  if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
		switch($comment_status){
			case "0":
			wp_notify_moderator($comment_ID);
			case "1": //Approved comment
			echo "success";
			$commentdata =& get_comment($comment_ID, ARRAY_A);
			$post =& get_post($commentdata['comment_post_ID']);
			wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
			break;
			default:
			echo "error";
		}
	exit;
	}
}